Merge branch 'master' of git://repo.or.cz/mqlkit
[mqlkit.git] / indicators / Meta COT Index.mq4.orig
blobc8f510d0c87b36adcc34ae5ee03b73ea7ab013bd
1 //+------------------------------------------------------------------+\r
2 //|                                               Meta COT Index.mq4 |\r
3 //|   Copyright © 2009, C-4 (Vasiliy Sokolov, Russia, St.-Petersburg,|\r
4 //|                                      2009), All Rights Reserved. |\r
5 //|                                                   vs-box@mail.ru |\r
6 //+------------------------------------------------------------------+\r
7 \r
8 // Ðàñ÷èòûâàåò èíäèêàòîð COT-Index\r
9 \r
10 #property copyright "Copyright © 2009, C-4 (Vasiliy Sokolov, SPb), All Rights Reserved."\r
11 #property link      "vs-box@mail.ru"\r
13 #property indicator_separate_window\r
14 #property  indicator_buffers 4\r
15 #property  indicator_color1  Green\r
16 #property  indicator_color2  Blue\r
17 #property  indicator_color3  Red\r
18 #property  indicator_color4  Silver\r
20 extern int  period=156;\r
21 int movement_index=6;\r
22 extern bool Show_iNoncomm=false;\r
23 extern bool Show_iOperators=true;\r
24 extern bool Show_iNonrep=false;\r
25 extern bool Show_iOI=true;\r
27 double i_open_interest[];\r
28 double i_noncomm[];\r
29 double i_operators[];\r
30 double i_nonrep[];\r
32 #include <cotlib.mq4>\r
34 int init()\r
35 {\r
36    if(init_data()==false)error=true;\r
37    if(error==false)load_data();\r
38    if(error==false)count_data();\r
39    //if(error==false)count_index(period);\r
40    SetParam();\r
41 }\r
43 int start()\r
44 {\r
45    if(error==true)Print("Íå óäàëîñü çàãðóçèòü äàííûå. Äàëüíåéøàÿ ðàáîòà íåâîçìîæíà");\r
46    DrowData();\r
47 }\r
49 void SetParam()\r
50 {\r
51    SetIndexStyle(0,DRAW_LINE,0,2);\r
52    SetIndexStyle(1,DRAW_LINE,0,2);\r
53    SetIndexStyle(2,DRAW_LINE,0,2);\r
54    SetIndexStyle(3,DRAW_LINE,0,2);\r
55    IndicatorDigits(2);\r
56    SetIndexEmptyValue(0,EMPTY_VALUE);\r
57    SetIndexEmptyValue(1,EMPTY_VALUE);\r
58    SetIndexEmptyValue(2,EMPTY_VALUE);\r
59    SetIndexEmptyValue(3,EMPTY_VALUE);\r
60    SetLevelValue(0,0.0);\r
61    SetLevelValue(1,20.0);\r
62    SetLevelValue(2,80.0);\r
63    SetLevelValue(3,100.0);\r
64    SetLevelStyle(0,0,Black);\r
65    //SetLevelStyle(0,1,Black);\r
66    //SetLevelStyle(0,1,Black);\r
67    //SetLevelStyle(0,1,Black);\r
68    if(load_cot_file==true)IndicatorShortName(StringConcatenate("Meta COT Index (",period,"): ",str_trim(cot_file)));\r
69    else IndicatorShortName(StringConcatenate("Meta COT Index (",period,"): ",name));\r
70    if(Show_iOI==true){\r
71       SetIndexBuffer(0,i_open_interest);\r
72       SetIndexLabel(0, "Open Interest");\r
73    }\r
74    if(Show_iNoncomm==true){\r
75       SetIndexBuffer(1,i_noncomm);\r
76       SetIndexLabel(1,"Index Noncommercial");\r
77    }\r
78    if(Show_iOperators==true){\r
79       SetIndexBuffer(2,i_operators);\r
80       SetIndexLabel(2,"Index Operators");\r
81    } \r
82    if(Show_iNonrep==true){\r
83       SetIndexBuffer(3,i_nonrep);\r
84       SetIndexLabel(3,"Index Nonreportable");\r
85    }\r
86 }\r
88 void DrowData()\r
89 {\r
90    int end_data=get_lastdata();\r
91    for(int i=0;i<end_data;i++){\r
92       if(Show_iOI)i_open_interest[i]=get_data(INDEX_OI, i);\r
93       if(Show_iNoncomm)i_noncomm[i]=get_data(INDEX_NONCOMM, i);\r
94       if(Show_iOperators)i_operators[i]=get_data(INDEX_OPERATORS, i);\r
95       if(Show_iNonrep)i_nonrep[i]=get_data(INDEX_NONREP,i);\r
96    }\r